package com.fastCms.business.bim.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fastCms.business.frame.constant.CommonConst;
import com.fastCms.business.bim.pojo.entity.Workduce;
import com.fastCms.business.bim.daos.WorkduceMapper;
import com.fastCms.business.bim.pojo.po.WorkduceListPO;
import com.fastCms.business.bim.service.WorkduceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 生产工序表
 * 服务实现类
 * </p>
 *
 * @author liusq
 * @since 2021-03-25
 */
@Service
public class WorkduceServiceImpl extends ServiceImpl<WorkduceMapper, Workduce> implements WorkduceService {

    @Override
    public List<Workduce> findValidAll(WorkduceListPO workducePO) {
        QueryWrapper<Workduce> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(workducePO.getProduce())) {
            queryWrapper.like("produce", workducePO.getProduce());
        }
        if (StringUtils.isNotBlank(workducePO.getMaters())) {
            queryWrapper.like("maters", workducePO.getMaters());
        }
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        return list(queryWrapper);
    }

    @Override
    public Workduce findById(String id) {
        QueryWrapper<Workduce> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        queryWrapper.eq("id", id);
        return getOne(queryWrapper);
    }
}
